package logic.SysRole

import cn.ibizlab.util.domain.EntityBase
import cn.ibizlab.util.helper.RuleUtils
import cn.ibizlab.util.security.AuthenticationUser
import cn.ibizlab.util.security.SpringContextHolder
import cn.ibizlab.core.authorization.domain.SysRole
import cn.ibizlab.core.authorization.service.SysRoleService
import cn.ibizlab.core.authorization.domain.SysGrantedAuthority
import cn.ibizlab.core.authorization.service.SysGrantedAuthorityService
import cn.ibizlab.core.authorization.domain.SysGrantedAuthority
import cn.ibizlab.core.authorization.service.SysGrantedAuthorityService
import cn.ibizlab.core.authorization.domain.SysGrantedAuthority
import cn.ibizlab.core.authorization.service.SysGrantedAuthorityService
import cn.ibizlab.core.authorization.domain.SysGrantedAuthority
import cn.ibizlab.core.authorization.service.SysGrantedAuthorityService
import com.alibaba.fastjson.JSONObject
import org.springframework.util.ObjectUtils

/**
 *  更新前处理
 */
class BeforeUpdate {

    //当前用户
    def curuser = AuthenticationUser.getAuthenticationUser()
    //传入变量
    def _default
    //权限循环临时变量
    def _authority_sub = new SysGrantedAuthority()
    //权限数组
    def _authoritys = new SysGrantedAuthority()
    //授权过滤参数
    def _granted_authority = new SysGrantedAuthority()
    //权限查询过滤
    def _granted_authority_filter = new SysGrantedAuthority()
    //返回参数
    def _return

    def execute(arg) {
        println 'running....'
        _default = arg
        
        
        
        
        _return = arg
        begin()
        println 'running end....'
        return _return
    }

    //开始
    def begin() {
    
        //连接名称
        if(true) {
            rawsfcode1()
        }
    }

    //执行脚本代码
    def rawsfcode1() {
        if(_default.getGrantedAuthorities()!=null) {
    _default.getGrantedAuthorities().forEach(item->item.setRoleId(_default.getId()).setId((String)item.getDefaultKey(true)));
}
drools.getKieRuntime().setGlobal("_default",_default);


        if(true) {
            end1()
        }
    }

    //结束
    def end1() {

    }

}
